package com.ruoyi.web.controller.danger;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.OneElectronFenceStatus;
import com.ruoyi.system.service.OneElectronFenceStatusService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 一号库区电子围栏状态(OneElectronFenceStatus)表控制层
 *
 * @author makejava
 * @since 2023-10-25 15:54:31
 */
@RestController
@RequestMapping("oneElectronFenceStatus")
public class OneElectronFenceStatusController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private OneElectronFenceStatusService oneElectronFenceStatusService;

    /**
     * 分页查询
     *
     * @param oneElectronFenceStatus 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(OneElectronFenceStatus oneElectronFenceStatus) {
        startPage();
        List<OneElectronFenceStatus> oneElectronFenceStatuses = oneElectronFenceStatusService.queryAll(oneElectronFenceStatus);
        return getDataTable(oneElectronFenceStatuses);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<OneElectronFenceStatus> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.oneElectronFenceStatusService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param oneElectronFenceStatus 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<OneElectronFenceStatus> add(OneElectronFenceStatus oneElectronFenceStatus) {
        return ResponseEntity.ok(this.oneElectronFenceStatusService.insert(oneElectronFenceStatus));
    }

    /**
     * 编辑数据
     *
     * @param oneElectronFenceStatus 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<OneElectronFenceStatus> edit(OneElectronFenceStatus oneElectronFenceStatus) {
        return ResponseEntity.ok(this.oneElectronFenceStatusService.update(oneElectronFenceStatus));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.oneElectronFenceStatusService.deleteById(id));
    }

}

